
<script type="text/javascript">
	$(document).ready(function(){
		var ret = false;
		$('#myButton').click(function(){
			$('#userForm').submit();
			if (!ret){
				return false;
			}
			var postdata = { 
                'passwd_old'    : hex_md5(hex_md5($('#oldpassword').val())), 
                'passwd_new1'   : hex_md5(hex_md5($('#new1password').val())),
                'passwd_new2'   : hex_md5(hex_md5($('#new2password').val()))
            };
           
			
			$.ajax({ 
	            url: "{:U('Admin/save_password')}",  
	            data: postdata,
	            dataType:'json',
	            type:'POST',
	            success: function(data){
	                if (data.ret == 1){
	                    $("#alert_box_admin").jk_alert({ msg: data.msg, type: 'success', show_time: 3500 });
	                   
	                    
	                }else{
	                    $("#alert_box_admin").jk_alert({ msg: data.msg, type: 'danger', show_time: 3500 });
	                }
	            }
	        });

		});
		
		$.formValidator.initConfig({
			formid:"userForm",
			onerror:function(msg){
				ret = false;
			},
			onsuccess:function(){
				ret = true;
				return false;
			}
		}); 
		$("#oldpassword").formValidator({empty:false, onshow:"请填写您当前正在使用的密码", onfocus:"请正确填写", oncorrect:" "})
		.functionValidator({fun:function(val,elem){
			if (val.length >=6 && val.length <= 20){
				return true;
			}else{
				return 	'密码输入错误，请重新输入';
			}
		}});
		$("#new1password").formValidator({empty:false, onshow:"请填写一个新密码",onfocus:"长度范围[6-20]",oncorrect:" "})
		.functionValidator({fun:function(val,elem){
			if (val.length >=6 && val.length <= 20){
				return true;
			}else{
				return 	'密码输入错误，请重新输入';
			}
		}});
		$("#new2password").formValidator({onshow:"再次输入密码",onfocus:"请重复输入一次密码",oncorrect:" "})
		.functionValidator({fun:function(val,elem){
			if (val.length >=6 && val.length <= 20 && val == $('#new1password').val()){
				return true;
			}else{
				return 	'两次密码输入不一致';
			}
		}});
	});
</script>

<div class="page-content" id="index_box" >
	<div class="row" >
		<div class="col-xs-12 col-sm-12 col-md-12 padding0">
			<form name="userForm" id="userForm" novalidate="" role="form"> 
				<div id="general_admin" class="form-horizontal">
					
					<div class="form-group">
						<label class="col-sm-2 control-label no-padding-right margintop5" for="form-field-1">
							<i class="icon-asterisk light-red smaller-60 middle"></i>&nbsp;原密码：
						</label>
						<div class="col-sm-6">
							<div class="input-group col-xs-10 col-sm-12 ">
								<input type="password" id="oldpassword" name="oldpassword" class="form-control"/>
							</div>
						
						</div>
						<div class="help-block col-sm-4" >
							<span id="oldpasswordTip"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label no-padding-right margintop5" for="form-field-1">
							<i class="icon-asterisk light-red smaller-60 middle"></i>&nbsp;新密码：
						</label>
						<div class="col-sm-6">
							<div class="input-group col-xs-10 col-sm-12 ">
								<input type="password" id="new1password" name="new1password" class="form-control"/>
							</div>
						</div>
						<div class="help-block col-sm-4" >
							<span id="new1passwordTip"></span>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label no-padding-right margintop5" for="form-field-1">
							<i class="icon-asterisk light-red smaller-60 middle"></i>&nbsp;确认新密码：
						</label>
						<div class="col-sm-6">
							<div class="input-group col-xs-10 col-sm-12 ">
								<input type="password" id="new2password" name="new2password" class="form-control"/>
							</div>
						</div>
						<div class="help-block col-sm-4" >
							<span id="new2passwordTip"></span>
						</div>
					</div>
				</div>
				<div id="alert_box_admin"></div>
				<div class="clearfix form-actions">
					<div class="col-md-offset-3 col-md-9">
						<button type="button" id="myButton" data-loading-text="正在修改,请稍候..." class="btn btn-success" autocomplete="off"><i class="icon-save bigger-150 middle"></i>修改密码</button>
					</div>
				</div>
			</form>
		</div>


	</div>

</div>
